package org.yxt.springcloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.yxt.springcloud.entities.CommonResult;
import org.yxt.springcloud.service.AccountService;

import java.math.BigDecimal;

@RestController
@RequestMapping(value = "account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    /**
     * 减去余额
     *
     * @param userId
     * @param money
     * @return
     */
    @PostMapping(value = "decrease")
    public CommonResult decrease(@RequestParam("userId") long userId, @RequestParam("money") BigDecimal money) {
        accountService.updateDetract(userId, money);
        return new CommonResult(1, "success");
    }
}
